package com.haojg.conf;

import com.haojg.service.MockWeatherService;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Description;

import java.util.function.Function;

@Configuration
public class WeatherFunctionConf {

//    @Bean
//    CommandLineRunner runner(ChatClient.Builder chatClientBuilder) {
//        return args -> {
//            ChatClient chatClient = chatClientBuilder.build();
//            String resp = chatClient.prompt().user("深圳的天气怎么样?")
//                    .functions("weatherFunction")
//                    .call().content();
//            System.out.println("resp = " + resp);
//        };
//    }

    @Bean
    @Description("根据位置获取天气信息")
    public Function<MockWeatherService.WeatherRequest, MockWeatherService.WeatherResponse> weatherFunction() {
        return new MockWeatherService();
    }

}

